//#ifndef decompdict_js
//#define decompdict_js 1

function DecompressDictionary () {
  this.revhashtable = [];
  this.nextcode = 0;
  this.numBits = 9;
  // Populate table with all possible character codes.
  for (var i = 0; i < 256; ++i) {
    this.revhashtable[this.nextcode++] = String.fromCharCode(i);
  }
}

DecompressDictionary.prototype = {
  
  Size : function () {
    return this.nextcode;
  },
  
  Insert : function (s) {
    this.revhashtable[this.nextcode++] = s;
    // How many bits are we currently using to represent values?
    // Look ahead one value because the decompressor lags one iteration
    // behind the compressor.
    this.numBits = Math.ceil(Math.log(this.nextcode + 2)/Math.LN2);
    return this.numBits;
  },
  
  LookupIndex : function (idx) {
    return this.revhashtable[idx];
  },
  
  ValSizeInBits : function () {
    return this.numBits;
  }
};

//#endif

